import pytest
import yaml
from Homework_01.Calculator import Calculator


class TestCalculator:

    def setup_class(self):
        self.calc = Calculator()

    def setup_method(self):
        print("开始计算")

    def teardown_method(self):
        print("结束计算")

    def teardown_class(self):
        print("结束测试")

    @pytest.mark.create
    @pytest.mark.parametrize("a, b, expected", yaml.safe_load(open("./TestCase_Add.yaml")))
    def test_add(self, a, b, expected):
        result = self.calc.add(a,b)
        assert result == expected

    @pytest.mark.div
    @pytest.mark.parametrize("a, b, expected", yaml.safe_load(open("./TestCase_Div.yaml")))
    def test_div(self, a, b, expected):
        result = self.calc.div(a, b)
        assert result == expected